<?php
include('../../includes/classes/core.php');
 
$c_data = date('Y-m-d H:i:s');
$aletter_id = $_REQUEST['id'];
$sum = floatval(0.0);

$res = mysql_fetch_assoc(mysql_query("SELECT	`a_letter`.`id` as `id`,
												`a_letter`.`fact_end_date` as `date`,
												CONCAT(`client`.`name`,'(',`client_objects`.`name`, ')') AS `client`,
												`a_letter`.`comment` as `comment`
								FROM			`a_letter`
								LEFT JOIN		`client_objects` ON `a_letter`.`client_object_id` = `client_objects`.`id`
								LEFT JOIN		`client` ON `client`.`id` = `client_objects`.`client_id`
								WHERE			`a_letter`.`id` = '$aletter_id'"));

function print1(){
	global $sum;
	global $res;
		$rsql = mysql_query("SELECT b_letter_details.barcode,
                    				production.`name`,	
                    				COUNT(DISTINCT part1.barcode) AS toneti,
                    				COUNT(DISTINCT part2.id) AS barabani,
                    				COUNT(DISTINCT part3.id) AS magnituri,
                    				COUNT(DISTINCT part4.id) as rezini,
                    				COUNT(DISTINCT part5.id) as gamwmendi,
                    				COUNT(DISTINCT part6.id) as dozirebis,
                    				COUNT(DISTINCT part7.id) AS chipi,
                    				COUNT(DISTINCT part8.id) AS korpusi,
                    				COUNT(DISTINCT part9.id) AS not_service,
                    				max(warehouse_detail.type),
                    				sum(IF(warehouse_detail.type=2 AND b_letter_details.part_type_id=2,0.00,b_letter_details.price))
                    FROM `b_letter_details`
                    JOIN  a_letter on b_letter_details.a_letter_id=a_letter.id
                    LEFT JOIN  production ON SUBSTR(b_letter_details.barcode, 6, 4) = production.id
                    LEFT JOIN  client ON SUBSTR(b_letter_details.barcode, 2, 4) = client.id
                    JOIN  warehouse_detail ON b_letter_details.warehouse_detail_id=warehouse_detail.id AND warehouse_detail.actived=1
                    LEFT JOIN  b_letter_details part1 ON  part1.part_type_id=2  AND part1.id =b_letter_details.id
                    LEFT JOIN  b_letter_details part2 ON  part2.part_type_id=3  AND part2.id =b_letter_details.id
                    LEFT JOIN  b_letter_details part3 ON  part3.part_type_id=4  AND part3.id =b_letter_details.id
                    LEFT JOIN  b_letter_details part4 ON  part4.part_type_id=5  AND part4.id =b_letter_details.id
                    LEFT JOIN  b_letter_details part5 ON  part5.part_type_id=6  AND part5.id =b_letter_details.id
                    LEFT JOIN  b_letter_details part6 ON  part6.part_type_id=7  AND part6.id =b_letter_details.id
                    LEFT JOIN  b_letter_details part7 ON  part7.part_type_id=8  AND part7.id =b_letter_details.id
                    LEFT JOIN  b_letter_details part8 ON  part8.part_type_id=9  AND part8.id =b_letter_details.id
                    LEFT JOIN  b_letter_details part9 ON  part9.part_type_id=16 AND part9.id =b_letter_details.id
                    WHERE      b_letter_details.a_letter_id=$res[id]
                    GROUP BY b_letter_details.a_letter_id, b_letter_details.barcode	");

	if( mysql_num_rows($rsql)  <= 14 ){
		for($j=0;$j<14;$j++){
			while ( $aRow = mysql_fetch_array( $rsql ) ){
				$data .= '<tr>';
				for ( $i = 0 ; $i < 13 ; $i++ ){
					if($i< 2 || $i > 10){
						if( $i == 11){
							if( $aRow[$i] == 2 ){
								$aRow[13] = '0.00';
								$data .= '<td><img src="../../media/images/0.gif"></td>';
							}else{
								$data .= '<td>&nbsp;</td>';
							}
						}else{
							$data .='<td>'.$aRow[$i].'</td>';
						}

					}else{
						if($aRow[$i] == 1){
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}
					if($i == 12){
						$sum = floatval($sum) + floatval($aRow[$i]);
					}
				}
				$data .= '</tr>';
				$j++;
			}
			$data .='
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
			        <td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>';
		}
		$data .='
	</table>
	<div style="padding-top: 2px;"></div>
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">
		<tr style="background-color: #D9D9D9; text-align: left;">
			<td style="text-align: left;">შენიშვნა</td>
		</tr>
		<tr>
			<td style="text-align: center;">
				'. $res['comment'] .'&nbsp;
			</td>
		</tr>
	</table>
	<div style="width: 480px; text-align: right; font-size: 10pt;">
		<p>თანხა სულ :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 30px; margin-left: 0px;">'. addNull($sum) .'&nbsp;&nbsp;ლარი</span></p>
	</div>
<div  style="font-size: 74%; text-align: center; ">
<pre>შპს "ჯი ეს იუნიტი"–ს წარმომადგენელმა ("მიმწოდებელი") გადასცა, ხოლო "მომსახურების
ობიექტის"წარმომადგენელმა ("მიმღებმა") ჩაიბარა ცხრილში აღნიშნული საქონელი და
 მომსახურება,რასაც ვადასტურებთ ხელმოწერით</pre>
</div>
	<div style="width: 480px; text-align: left;">
		<p style="font-weight: normal; font-size: 9pt;">მიმწოდებელი :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="width: 480px; text-align: left; padding-left: 10px;">
		<p style="font-weight: normal; font-size: 9pt; margin-left: 30px;">მიმღები :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="position: relative; top: -40px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -23px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -34px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -73px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -44px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(1/1)</div>
</div>';
	}else if( mysql_num_rows($rsql) <= 42){
		for($j=0;$j<21;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(1/2)</div>
									</div>';
	$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';
	for($j=0;$j<21;$j++){
		while ( $aRow = mysql_fetch_array( $rsql ) ){
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 0 ){
						$data .= '<td style="width: 150px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 1 ){
						$data .= '<td style="width: 170px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 12 ){
						$data .= '<td style="font-size: 9pt;width: 60px;">'.$aRow[$i].'</td>';
					}
					if( $i == 11 ){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td  style="width: 25px;"><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td style="width: 25px;">&nbsp;</td>';
						}
					}
				}else{
					if($aRow[$i] == 1){
						$data .= '<td style="width: 25px;"><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td style="width: 25px;">&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
					addNull( $aRow[$i] );
				}
			}
			$data .= '</tr>';
			$j++;
		}
		$data .='
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
		    <td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>';
	}
	$data .='
	</table>
	<div style="padding-top: 2px;"></div>
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">
		<tr style="background-color: #D9D9D9; text-align: left;">
			<td style="text-align: left;">შენიშვნა</td>
		</tr>
		<tr>
			<td style="text-align: center;">
				'. $res['comment'] .'&nbsp;
			</td>
		</tr>
	</table>
	<div style="width: 480px; text-align: right; font-size: 10pt;">
		<p>თანხა სულ :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 30px; margin-left: 0px;">'. addNull($sum) .'&nbsp;&nbsp;ლარი</span></p>
	</div>
<div  style="font-size: 74%; text-align: center; ">
<pre>შპს "ჯი ეს იუნიტი"–ს წარმომადგენელმა ("მიმწოდებელი") გადასცა, ხოლო "მომსახურების
ობიექტის"წარმომადგენელმა ("მიმღებმა") ჩაიბარა ცხრილში აღნიშნული საქონელი და
მომსახურება,რასაც ვადასტურებთ ხელმოწერით</pre>
</div>
	<div style="width: 480px; text-align: left;">
		<p style="font-weight: normal; font-size: 9pt;">მიმწოდებელი :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="width: 480px; text-align: left; padding-left: 10px;">
		<p style="font-weight: normal; font-size: 9pt; margin-left: 30px;">მიმღები :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="position: relative; top: -40px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -23px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -34px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -73px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -44px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(2/2)</div>
	</div>';
	}else if( mysql_num_rows($rsql) <= 66){
		for($j=0;$j<21;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(1/3)</div>
									</div>';

		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(2/3)</div>
									</div>';


	$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';
	for($j=0;$j<21;$j++){
		while ( $aRow = mysql_fetch_array( $rsql ) ){
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 0 ){
						$data .= '<td style="width: 150px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 1 ){
						$data .= '<td style="width: 170px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 12 ){
						$data .= '<td style="font-size: 9pt;width: 60px;">'.$aRow[$i].'</td>';
					}
					if( $i == 11 ){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td  style="width: 25px;"><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td style="width: 25px;">&nbsp;</td>';
						}
					}
				}else{
					if($aRow[$i] == 1){
						$data .= '<td style="width: 25px;"><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td style="width: 25px;">&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
					addNull( $aRow[$i] );
				}
			}
			$data .= '</tr>';
			$j++;
		}
		$data .='
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
		            <td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>';
	}
	$data .='
	</table>
	<div style="padding-top: 2px;"></div>
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">
		<tr style="background-color: #D9D9D9; text-align: left;">
			<td style="text-align: left;">შენიშვნა</td>
		</tr>
		<tr>
			<td style="text-align: center;">
				'. $res['comment'] .'&nbsp;
			</td>
		</tr>
	</table>
	<div style="width: 480px; text-align: right; font-size: 10pt;">
		<p>თანხა სულ :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 30px; margin-left: 0px;">'. addNull($sum) .'&nbsp;&nbsp;ლარი</span></p>
	</div>
<div  style="font-size: 74%; text-align: center; ">
<pre>შპს "ჯი ეს იუნიტი"–ს წარმომადგენელმა ("მიმწოდებელი") გადასცა, ხოლო "მომსახურების
ობიექტის"წარმომადგენელმა ("მიმღებმა") ჩაიბარა ცხრილში აღნიშნული საქონელი და
მომსახურება,რასაც ვადასტურებთ ხელმოწერით</pre>
</div>
	<div style="width: 480px; text-align: left;">
		<p style="font-weight: normal; font-size: 9pt;">მიმწოდებელი :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="width: 480px; text-align: left; padding-left: 10px;">
		<p style="font-weight: normal; font-size: 9pt; margin-left: 30px;">მიმღები :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="position: relative; top: -40px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -23px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -34px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -73px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -44px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(3/3)</div>
	</div>';
	}else if( mysql_num_rows($rsql) <= 90){
		for($j=0;$j<21;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(1/4)</div>
									</div>';

		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(2/4)</div>
									</div>';


		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(3/4)</div>
									</div>';

	$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';
	for($j=0;$j<21;$j++){
		while ( $aRow = mysql_fetch_array( $rsql ) ){
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 0 ){
						$data .= '<td style="width: 150px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 1 ){
						$data .= '<td style="width: 170px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 12 ){
						$data .= '<td style="font-size: 9pt;width: 60px;">'.$aRow[$i].'</td>';
					}
					if( $i == 11 ){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td  style="width: 25px;"><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td style="width: 25px;">&nbsp;</td>';
						}
					}
				}else{
					if($aRow[$i] == 1){
						$data .= '<td style="width: 25px;"><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td style="width: 25px;">&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
					addNull( $aRow[$i] );
				}
			}
			$data .= '</tr>';
			$j++;
		}
		$data .='
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>';
	}
	$data .='
	</table>
	<div style="padding-top: 2px;"></div>
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">
		<tr style="background-color: #D9D9D9; text-align: left;">
			<td style="text-align: left;">შენიშვნა</td>
		</tr>
		<tr>
			<td style="text-align: center;">
				'. $res['comment'] .'&nbsp;
			</td>
		</tr>
	</table>
	<div style="width: 480px; text-align: right; font-size: 10pt;">
		<p>თანხა სულ :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 30px; margin-left: 0px;">'. addNull($sum) .'&nbsp;&nbsp;ლარი</span></p>
	</div>
<div  style="font-size: 74%; text-align: center; ">
<pre>შპს "ჯი ეს იუნიტი"–ს წარმომადგენელმა ("მიმწოდებელი") გადასცა, ხოლო "მომსახურების
ობიექტის"წარმომადგენელმა ("მიმღებმა") ჩაიბარა ცხრილში აღნიშნული საქონელი და
მომსახურება,რასაც ვადასტურებთ ხელმოწერით</pre>
</div>
	<div style="width: 480px; text-align: left;">
		<p style="font-weight: normal; font-size: 9pt;">მიმწოდებელი :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="width: 480px; text-align: left; padding-left: 10px;">
		<p style="font-weight: normal; font-size: 9pt; margin-left: 30px;">მიმღები :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="position: relative; top: -40px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -23px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -34px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -73px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -44px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(4/4)</div>
	</div>';
	}else if( mysql_num_rows($rsql) <= 114){
		for($j=0;$j<21;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[11] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(1/5)</div>
									</div>';

		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(2/5)</div>
									</div>';
		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(3/5)</div>
									</div>';


		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(4/5)</div>
									</div>';

	$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';
	for($j=0;$j<21;$j++){
		while ( $aRow = mysql_fetch_array( $rsql ) ){
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 0 ){
						$data .= '<td style="width: 150px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 1 ){
						$data .= '<td style="width: 170px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 12 ){
						$data .= '<td style="font-size: 9pt;width: 60px;">'.$aRow[$i].'</td>';
					}
					if( $i == 11 ){
						if( $aRow[$i] == 2 ){
							$aRow[13] = '0.00';
							$data .= '<td  style="width: 25px;"><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td style="width: 25px;">&nbsp;</td>';
						}
					}
				}else{
					if($aRow[$i] == 1){
						$data .= '<td style="width: 25px;"><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td style="width: 25px;">&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
					addNull( $aRow[$i] );
				}
			}
			$data .= '</tr>';
			$j++;
		}
		$data .='
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>';
	}
	$data .='
	</table>
	<div style="padding-top: 2px;"></div>
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">
		<tr style="background-color: #D9D9D9; text-align: left;">
			<td style="text-align: left;">შენიშვნა</td>
		</tr>
		<tr>
			<td style="text-align: center;">
				'. $res['comment'] .'&nbsp;
			</td>
		</tr>
	</table>
	<div style="width: 480px; text-align: right; font-size: 10pt;">
		<p>თანხა სულ :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 30px; margin-left: 0px;">'. addNull($sum) .'&nbsp;&nbsp;ლარი</span></p>
	</div>
<div  style="font-size: 74%; text-align: center; ">
<pre>შპს "ჯი ეს იუნიტი"–ს წარმომადგენელმა ("მიმწოდებელი") გადასცა, ხოლო "მომსახურების
ობიექტის"წარმომადგენელმა ("მიმღებმა") ჩაიბარა ცხრილში აღნიშნული საქონელი და
მომსახურება,რასაც ვადასტურებთ ხელმოწერით</pre>
</div>
	<div style="width: 480px; text-align: left;">
		<p style="font-weight: normal; font-size: 9pt;">მიმწოდებელი :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="width: 480px; text-align: left; padding-left: 10px;">
		<p style="font-weight: normal; font-size: 9pt; margin-left: 30px;">მიმღები :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="position: relative; top: -40px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -23px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -34px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -73px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -44px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(4/4)</div>
	</div>';
	}else if( mysql_num_rows($rsql) <= 138){
		for($j=0;$j<21;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 350px;font-weight: normal; font-size: 6pt;">(1/5)</div>
									</div>';

		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(2/5)</div>
									</div>';
		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(3/5)</div>
									</div>';


		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 9){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(3/5)</div>
									</div>';

		$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

		for($j=0;$j<24;$j++){
			$aRow = mysql_fetch_array( $rsql );
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 11){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td>&nbsp;</td>';
						}
					}else{
						$data .='<td>'.$aRow[$i].'</td>';
					}

				}else{
					if($aRow[$i] == 1){
						$data .= '<td><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td>&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
				}
			}
			$data .= '</tr>';
		}
		$data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(4/5)</div>
									</div>';

	$data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';
	for($j=0;$j<24;$j++){
		while ( $aRow = mysql_fetch_array( $rsql ) ){
			$data .= '<tr>';
			for ( $i = 0 ; $i < 13 ; $i++ ){
				if($i< 2 || $i > 10){
					if( $i == 0 ){
						$data .= '<td style="width: 150px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 1 ){
						$data .= '<td style="width: 170px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
					}
					if( $i == 12 ){
						$data .= '<td style="font-size: 9pt;width: 60px;">'.$aRow[$i].'</td>';
					}
					if( $i == 11 ){
						if( $aRow[$i] == 2 ){
							$aRow[12] = '0.00';
							$data .= '<td  style="width: 25px;"><img src="../../media/images/0.gif"></td>';
						}else{
							$data .= '<td style="width: 25px;">&nbsp;</td>';
						}
					}
				}else{
					if($aRow[$i] == 1){
						$data .= '<td style="width: 25px;"><img src="../../media/images/0.gif"></td>';
					}else{
						$data .= '<td style="width: 25px;">&nbsp;</td>';
					}
				}
				if($i == 12){
					$sum = floatval($sum) + floatval($aRow[$i]);
					addNull( $aRow[$i] );
				}
			}
			$data .= '</tr>';
			$j++;
		}
		$data .='
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
		            <td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>';
	}
	$data .='
	</table>
	<div style="padding-top: 2px;"></div>
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">
		<tr style="background-color: #D9D9D9; text-align: left;">
			<td style="text-align: left;">შენიშვნა</td>
		</tr>
		<tr>
			<td style="text-align: center;">
				'. $res['comment'] .'&nbsp;
			</td>
		</tr>
	</table>
	<div style="width: 480px; text-align: right; font-size: 10pt;">
		<p>თანხა სულ :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 30px; margin-left: 0px;">'. addNull($sum) .'&nbsp;&nbsp;ლარი</span></p>
	</div>
<div  style="font-size: 74%; text-align: center; ">
<pre>შპს "ჯი ეს იუნიტი"–ს წარმომადგენელმა ("მიმწოდებელი") გადასცა, ხოლო "მომსახურების
ობიექტის"წარმომადგენელმა ("მიმღებმა") ჩაიბარა ცხრილში აღნიშნული საქონელი და
მომსახურება,რასაც ვადასტურებთ ხელმოწერით</pre>
</div>
	<div style="width: 480px; text-align: left;">
		<p style="font-weight: normal; font-size: 9pt;">მიმწოდებელი :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="width: 480px; text-align: left; padding-left: 10px;">
		<p style="font-weight: normal; font-size: 9pt; margin-left: 30px;">მიმღები :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="position: relative; top: -40px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -23px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -34px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -73px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -44px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(4/4)</div>
	</div>';
	}else {
	    for($j=0;$j<23;$j++){
	        $aRow = mysql_fetch_array( $rsql );
	        $data .= '<tr>';
	        for ( $i = 0 ; $i < 13 ; $i++ ){
	            if($i< 2 || $i > 10){
	                if( $i == 11){
	                    if( $aRow[$i] == 2 ){
	                        $aRow[12] = '0.00';
	                        $data .= '<td><img src="../../media/images/0.gif"></td>';
	                    }else{
	                        $data .= '<td>&nbsp;</td>';
	                    }
	                }else{
	                    $data .='<td>'.$aRow[$i].'</td>';
	                }

	            }else{
	                if($aRow[$i] == 1){
	                    $data .= '<td><img src="../../media/images/0.gif"></td>';
	                }else{
	                    $data .= '<td>&nbsp;</td>';
	                }
	            }
	            if($i == 12){
	                $sum = floatval($sum) + floatval($aRow[$i]);
	            }
	        }
	        $data .= '</tr>';
	    }
	    $data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 350px;font-weight: normal; font-size: 6pt;">(1/5)</div>
									</div>';

	    $data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

	    for($j=0;$j<32;$j++){
	        $aRow = mysql_fetch_array( $rsql );
	        $data .= '<tr>';
	        for ( $i = 0 ; $i < 13 ; $i++ ){
	            if($i< 2 || $i > 10){
	                if( $i == 11){
	                    if( $aRow[$i] == 2 ){
	                        $aRow[12] = '0.00';
	                        $data .= '<td><img src="../../media/images/0.gif"></td>';
	                    }else{
	                        $data .= '<td>&nbsp;</td>';
	                    }
	                }else{
	                    $data .='<td>'.$aRow[$i].'</td>';
	                }

	            }else{
	                if($aRow[$i] == 1){
	                    $data .= '<td><img src="../../media/images/0.gif"></td>';
	                }else{
	                    $data .= '<td>&nbsp;</td>';
	                }
	            }
	            if($i == 12){
	                $sum = floatval($sum) + floatval($aRow[$i]);
	            }
	        }
	        $data .= '</tr>';
	    }
	    $data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(2/5)</div>
									</div>';
	    $data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

	    for($j=0;$j<32;$j++){
	        $aRow = mysql_fetch_array( $rsql );
	        $data .= '<tr>';
	        for ( $i = 0 ; $i < 13 ; $i++ ){
	            if($i< 2 || $i > 10){
	                if( $i == 11){
	                    if( $aRow[$i] == 2 ){
	                        $aRow[12] = '0.00';
	                        $data .= '<td><img src="../../media/images/0.gif"></td>';
	                    }else{
	                        $data .= '<td>&nbsp;</td>';
	                    }
	                }else{
	                    $data .='<td>'.$aRow[$i].'</td>';
	                }

	            }else{
	                if($aRow[$i] == 1){
	                    $data .= '<td><img src="../../media/images/0.gif"></td>';
	                }else{
	                    $data .= '<td>&nbsp;</td>';
	                }
	            }
	            if($i == 12){
	                $sum = floatval($sum) + floatval($aRow[$i]);
	            }
	        }
	        $data .= '</tr>';
	    }
	    $data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(3/5)</div>
									</div>';


	    $data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

	    for($j=0;$j<32;$j++){
	        $aRow = mysql_fetch_array( $rsql );
	        $data .= '<tr>';
	        for ( $i = 0 ; $i < 13 ; $i++ ){
	            if($i< 2 || $i > 10){
	                if( $i == 11){
	                    if( $aRow[$i] == 2 ){
	                        $aRow[12] = '0.00';
	                        $data .= '<td><img src="../../media/images/0.gif"></td>';
	                    }else{
	                        $data .= '<td>&nbsp;</td>';
	                    }
	                }else{
	                    $data .='<td>'.$aRow[$i].'</td>';
	                }

	            }else{
	                if($aRow[$i] == 1){
	                    $data .= '<td><img src="../../media/images/0.gif"></td>';
	                }else{
	                    $data .= '<td>&nbsp;</td>';
	                }
	            }
	            if($i == 12){
	                $sum = floatval($sum) + floatval($aRow[$i]);
	            }
	        }
	        $data .= '</tr>';
	    }
	    $data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(3/5)</div>
									</div>';

	    $data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';

	    for($j=0;$j<32;$j++){
	        $aRow = mysql_fetch_array( $rsql );
	        $data .= '<tr>';
	        for ( $i = 0 ; $i < 13 ; $i++ ){
	            if($i< 2 || $i > 10){
	                if( $i == 11){
	                    if( $aRow[$i] == 2 ){
	                        $aRow[12] = '0.00';
	                        $data .= '<td><img src="../../media/images/0.gif"></td>';
	                    }else{
	                        $data .= '<td>&nbsp;</td>';
	                    }
	                }else{
	                    $data .='<td>'.$aRow[$i].'</td>';
	                }

	            }else{
	                if($aRow[$i] == 1){
	                    $data .= '<td><img src="../../media/images/0.gif"></td>';
	                }else{
	                    $data .= '<td>&nbsp;</td>';
	                }
	            }
	            if($i == 12){
	                $sum = floatval($sum) + floatval($aRow[$i]);
	            }
	        }
	        $data .= '</tr>';
	    }
	    $data .= '</table>
	<div style="position: relative; top: 2px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(4/5)</div>
									</div>';

	    $data .= '
	<div align=center style="page-break-before: always;">
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">';
	    for($j=0;$j<27;$j++){
	        while ( $aRow = mysql_fetch_array( $rsql ) ){
	            $data .= '<tr>';
	            for ( $i = 0 ; $i < 13 ; $i++ ){
	                if($i< 2 || $i > 10){
	                    if( $i == 0 ){
	                        $data .= '<td style="width: 150px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
	                    }
	                    if( $i == 1 ){
	                        $data .= '<td style="width: 170px;font-size: 10.0pt;">'.$aRow[$i].'</td>';
	                    }
	                    if( $i == 12 ){
	                        $data .= '<td style="font-size: 9pt;width: 60px;">'.$aRow[$i].'</td>';
	                    }
	                    if( $i == 11 ){
	                        if( $aRow[$i] == 2 ){
	                            $aRow[12] = '0.00';
	                            $data .= '<td  style="width: 25px;"><img src="../../media/images/0.gif"></td>';
	                        }else{
	                            $data .= '<td style="width: 25px;">&nbsp;</td>';
	                        }
	                    }
	                }else{
	                    if($aRow[$i] == 1){
	                        $data .= '<td style="width: 25px;"><img src="../../media/images/0.gif"></td>';
	                    }else{
	                        $data .= '<td style="width: 25px;">&nbsp;</td>';
	                    }
	                }
	                if($i == 12){
	                    $sum = floatval($sum) + floatval($aRow[$i]);
	                    addNull( $aRow[$i] );
	                }
	            }
	            $data .= '</tr>';
	            $j++;
	        }
	        $data .='
				<tr>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
		            <td>&nbsp;</td>
					<td>&nbsp;</td>
					<td>&nbsp;</td>
				</tr>';
	    }
	    $data .='
	</table>
	<div style="padding-top: 2px;"></div>
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">
		<tr style="background-color: #D9D9D9; text-align: left;">
			<td style="text-align: left;">შენიშვნა</td>
		</tr>
		<tr>
			<td style="text-align: center;">
				'. $res['comment'] .'&nbsp;
			</td>
		</tr>
	</table>
	<div style="width: 480px; text-align: right; font-size: 10pt;">
		<p>თანხა სულ :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 30px; margin-left: 0px;">'. addNull($sum) .'&nbsp;&nbsp;ლარი</span></p>
	</div>
<div  style="font-size: 74%; text-align: center; ">
<pre>შპს "ჯი ეს იუნიტი"–ს წარმომადგენელმა ("მიმწოდებელი") გადასცა, ხოლო "მომსახურების
ობიექტის"წარმომადგენელმა ("მიმღებმა") ჩაიბარა ცხრილში აღნიშნული საქონელი და
მომსახურება,რასაც ვადასტურებთ ხელმოწერით</pre>
</div>
	<div style="width: 480px; text-align: left;">
		<p style="font-weight: normal; font-size: 9pt;">მიმწოდებელი :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="width: 480px; text-align: left; padding-left: 10px;">
		<p style="font-weight: normal; font-size: 9pt; margin-left: 30px;">მიმღები :&nbsp;<span style="border-bottom: 1px solid #000; padding: 0 120px; margin-left: 0px;"></span><span style="border-bottom: 1px solid #000; padding: 0 60px; margin-left: 30px;"></span></p>
	</div>
	<div style="position: relative; top: -40px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -23px; left: 20px; width: 330px;font-weight: normal; font-size: 6pt;">სახელი&nbsp;&nbsp;&nbsp;&nbsp; გვარი</div>
	<div style="position: relative; top: -34px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -73px; left: 190px; width: 330px;font-weight: normal; font-size: 6pt;">ხელმოწერა</div>
	<div style="position: relative; top: -44px; left: 225px; width: 330px;font-weight: normal; font-size: 6pt;">(4/4)</div>
	</div>';

	}

	return $data;
}

function addNull($sum){
	GLOBAL $sum;
	if($sum != '' && $sum != '0'){
		$parts = explode('.', $sum);
		$sum1 ='';
		$sum1.= $parts[0];
		if( $parts[1] == ''){
			$sum1.= '.00';
		}else{
			$sum1 = $sum;
		}
		return $sum1;
	}else{
		return '0.00';
	}
}
?>


<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>ბ ბარათი</title>
	<style type="text/css">

		body{
			text-align:center;
		}

		.job-blank{
			width: 480px;
		}

		.job-blank td{
			text-align: center;
			font-weight: bold;
			font-family: Sylfaen, Arial, sans-serif;
			font-size: 10.0pt;
		}

		.job-blank .rotate{
			font-size: 8pt;
			writing-mode: tb-rl;
			-webkit-transform: rotate(270deg);
			-moz-transform: rotate(270deg);
			-o-transform: rotate(270deg);
			white-space: nowrap;
			display: block;
			width: 8px;
			vertical-align: bottom;
		}

		.style1{
			margin-top: 40px;
			margin-left: 4px;
			vertical-align: bottom;
		}

		.style2{
			margin-top: 75px;
			margin-left: 4px;
			vertical-align: bottom;
		}


		.sub{
			width: 25px;
		}
	</style>
</head>

<body >
<div align=center>
	<table border="0" class="job-blank" cellpadding="0" cellspacing="0">
		<tr>
			<td colspan="4" style="padding: 2px; vertical-align:top;border-bottom:6px double;">
					<div style="float: left;">
					<img src="logo.jpg" width="58" height="58" style="float: left;">
					<table border="0" cellpadding="0" cellspacing="0" style="padding-left: 10px;">
							<tr>
								<td style="padding-top: 10px; font-size: 70%;">service@</td>
								<th rowspan="2" style="font-size:180%; padding-bottom: 10px;">gsunity.ge</th>
							</tr>
							<tr>
								<td style="padding-bottom: 10px; font-size: 70%;">w&nbsp;w&nbsp;w.</td>
							</tr>
					</table>
					</div>
					<div style="float: right;">
					<table border="0" cellpadding="0" cellspacing="0" >
						<tr>
							<th style="font-size: 75%;">შპს "ჯი ეს უნიტი"</th>
						</tr>
						<tr>
							<td style="font-size: 65%;">თბილისი, პოლიტკოვსკაიას ქ. № 10</td>
						</tr>
						<tr>
							<td style="font-size: 65%;">Tel: 2 555 118</td>
						</tr>
						<tr>
							<td style=" font-size: 65%;">Mob: 595 74 95 74; 595 40 40 13</td>
						</tr>
					</table>
					</div>
			</td>
		</tr>
		<tr>
			<!-- <td rowspan="4" valign="top" style="padding: 2px;"><img src="logo.jpg" width="68" height="68" style="float: left;"></td> -->
			<td style="font-weight: normal; padding-top: 5px; text-align: left;">მიღება ჩაბარების აქტი №:<span style="border-bottom: 1px solid #000; padding: 0 30px; margin-left: 10px; font-weight: bold;">ბ – &nbsp;<?php echo $res['id']; ?></span><img alt="testing" src="barcode.php?text=b – <?= $_REQUEST['id']?>" style="float:right; margin-top:7px;" /></td>
		</tr>
		<tr>
			<td style="text-align: left; font-weight: normal;">თარიღი :&nbsp;<span style="border-bottom: 1px solid #000; font-weight: bold;"><?php echo $res['date']; ?></span></td>
		</tr>
		<tr>
			<td  style="font-weight: normal; text-align: left; font-size: 9pt;">მომსახურების ობიექტი:<div style="display: inline;"><span style="border-bottom: 1px solid #000; margin-left: 5px; font-weight: bold">&nbsp;"<?php echo $res['client']; ?>"</span></div></td>
		</tr>
	</table>
	<div style="padding-top: 5px;"></div>
	<table border="1" class="job-blank" cellpadding="0" cellspacing="0">
		<tr style="background-color: #D9D9D9; font-size: 9pt;font-weight: normal; ">
			<td>&nbsp;</td>
			<td>&nbsp;</td>
			<td colspan="10" style=" font-size: 9pt;font-weight: normal; ">ჩატარებული სამუშაოები</td>
			<td>&nbsp;</td>
		</tr>
		<tr style="background-color: #D9D9D9;">
			<td style="width: 150px;font-size: 9pt;"><span>შტრიხკოდი</span></td>
			<td style="width: 170px;font-size: 9pt;"><span>მოდელი</span></td>
			<td class="sub" ><span class="rotate style1">ტონერი</span></td>
			<td class="sub" ><span class="rotate style1">ბარაბანი</span></td>
			<td class="sub" ><span class="rotate style2">მაგნიტ. ლილ.</span></td>
			<td class="sub" ><span class="rotate style2">რეზინის PCR</span></td>
			<td class="sub" ><span class="rotate style2">გამწ. რაკელი</span></td>
			<td class="sub" ><span class="rotate style2">დოზ. რაკელი</span></td>
			<td class="sub" ><span class="rotate style1">ჩიპი</span></td>
			<td class="sub" ><span class="rotate style1">კორპუსი</span></td>
			<td class="sub" ><span class="rotate style2">სევისის გარეშე</span></td>
			<td class="sub" ><span class="rotate style2">საგარანტიო</span></td>
			<td style="font-size: 9pt;width: 60px;">&nbsp;ფასი&nbsp;</td>
		</tr>
		<?php echo print1();?>

</body>

</html>